package com.hackerrank.challenges.htmlattributes;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Solution {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		in.nextLine();
		String id = "[a-zA-Z][a-zA-Z0-9]*", attrValue = "((\"[^\"]*\")|('[^']*'))";
		Map<String, Set<String>> tagNames = new HashMap<String, Set<String>>();
		for(int i = 0; i < N; i++) {
			Matcher m = Pattern.compile("<" + id + "( +" + id + " *= *" + attrValue + ")*").matcher(in.nextLine());
			while(m.find()) {
				String s = m.group();
				int si = s.indexOf(' ');
				if(si < 0)
					si = s.length();
				String tagName = s.substring(1, si);
				Set<String> attrNames = tagNames.get(tagName);
				if(attrNames == null) {
					attrNames = new HashSet<String>();
					tagNames.put(tagName, attrNames);
				}
				String myAttrNames[] = s.substring(si).trim().replaceAll(" *= *" + attrValue, "").split(" +");
				for(int j = 0; j < myAttrNames.length; j++)
					attrNames.add(myAttrNames[j]);
			}
		}
		Set<String> myTagNames = tagNames.keySet();
		String sortedTagNames[] = new String[myTagNames.size()];
		myTagNames.toArray(sortedTagNames);
		Arrays.sort(sortedTagNames);
		for(String tagName : sortedTagNames) {
			System.out.print(tagName + ":");
			Set<String> attrNames = tagNames.get(tagName);
			String[] sortedAttrNames = new String[attrNames.size()];
			sortedAttrNames = attrNames.toArray(sortedAttrNames);
			Arrays.sort(sortedAttrNames);
			if(sortedAttrNames.length > 0) {
				System.out.print(sortedAttrNames[0]);
				for(int i = 1; i < sortedAttrNames.length; i++)
					System.out.print("," + sortedAttrNames[i]);
			}
			System.out.println();
		}
	}
}
